﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Light.Utility;
using System.Data;

namespace Test.Website
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnUpload_Click(object sender, EventArgs e)
        {
            if (FileUpload1.HasFile)
            {
                string tempPath = Server.MapPath("./Uploads/" + FileUpload1.FileName);
                this.TextBox1.Text = tempPath;

                FileUpload1.SaveAs(tempPath);

                DataSet ds = ExcelHelper.ReadToDataSet(tempPath);

                this.GridView1.DataSource = ds;
                this.GridView1.DataBind();
            }
        }

        protected void btnDownload_Click(object sender, EventArgs e)
        {
            DataSet dt = ExcelHelper.ReadToDataSet(this.TextBox1.Text);
            ExcelHelper.ResponseWrite(dt, null);
        }
    }
}
